package com.hyt.it.ogt.controller.ykcj.grade;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.hyt.it.ogt.controller.base.BaseController;
import com.hyt.it.ogt.ykcj.common.core.domain.AjaxResult;
import com.hyt.it.ogt.ykcj.common.exception.CustomException;
import com.hyt.it.ogt.ykcj.domain.vo.ExamPublishVo;
import com.hyt.it.ogt.ykcj.service.grade.IEnterpriseExamineePublishInfoService;

import groovy.util.logging.Slf4j;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiSort;

/**
 * 企业招聘考生发布成绩信息Controller
 *
 * @author liying
 * @date 2021-11-19
 */
@Api(tags = "grade.11.企业招聘考生发布成绩信息")
@ApiSort(value = 211)
@RestController
@RequestMapping("/enterprise/publish/info")
@Slf4j
public class EnterpriseExamineePublishInfoController extends BaseController {

    @Autowired
    private IEnterpriseExamineePublishInfoService enterpriseExamineePublishInfoService;

    /**
     * 获取发布信息
     *
     * @param examId
     * @return
     */
    @ApiOperation(value = "获取考试发布信息", response = ExamPublishVo.class)
    @PostMapping("/detail/{examId}")
    public AjaxResult publishDetail(@PathVariable("examId") String examId) {
        return AjaxResult.success(enterpriseExamineePublishInfoService.selectExamPublishInfoById(examId));
    }

    /**
     * 保存发布信息
     *
     * @param examPublishVo
     * @return
     */
    @ApiOperation(value = "保存考试发布信息")
    @PostMapping("/saveExamPublishInfo")
    public AjaxResult saveExamPublishInfo(@RequestBody ExamPublishVo examPublishVo) {
        try {
            enterpriseExamineePublishInfoService.saveExamPublishInfoVo(examPublishVo);
            return AjaxResult.success();
        } catch (CustomException e) {
            logger.error("saveExamPublishInfo:CustomException", e);
            return AjaxResult.error(e.getMessage());
        } catch (Exception e) {
            logger.error("saveExamPublishInfo:Exception", e);
            return AjaxResult.error();
        }
    }
}
